package com.yunyao.framework.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunyao.common.constant.enums.DataDeletedStatus;
import com.yunyao.dao.model.BamuOss;
import com.yunyao.dao.service.bamu.IBamuOssService;
import com.yunyao.framework.service.system.OssService;
import com.yunyao.framework.vo.OssVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OssServiceImpl implements OssService {
    @Autowired
    private IBamuOssService iOssService;

    @Override
    public OssVo getOssConfigByCode(String code) {
        LambdaQueryWrapper<BamuOss> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BamuOss::getOssCode, code).eq(BamuOss::getIsDeleted, DataDeletedStatus.NO.getType());
        return convertToOssVo(iOssService.getOne(queryWrapper));
    }

    private OssVo convertToOssVo(BamuOss bamuOss){
        OssVo ossVo = new OssVo();
        BeanUtils.copyProperties(bamuOss, ossVo);
        return ossVo;
    }
}
